<template>
  <div>
    <el-button class='tixian-text' type="text" @click="centerDialogVisible = true" >提现</el-button>
    <el-dialog id='tixian-tlt' title="提现" :visible.sync="centerDialogVisible" width="50%" center>
      <div class="ti-content">
        <span>账户余额：</span>
        <span class='num'>&yen {{ myInfo.balance }}</span>
      </div>
      <div class="ti-other" v-show='bindCard' >
        <i class="el-icon-error"></i>
        <span>您尚未绑定银行账户，请先绑定银行账户！</span>
      </div>
      <div class="button" v-show='bindCard' >
        <a href="###">
          <el-button type="info" icon="el-icon-circle-plus-outline">绑定银行账户</el-button>
        </a>
      </div>
      <div class="button" v-show='!bindCard' >
        <div style="margin: 5px">
          <el-input v-model='form.amount' type='number'  style="width: 250px" placeholder="请输入提现金额"></el-input>
        </div>
          <div style="margin: 5px">
            <el-input v-model='form.pass' type='password'  style="width: 250px" placeholder="请输入提现密码"></el-input>
          </div>
          <el-button type="info" icon="el-icon-circle-plus-outline" @click='request_tixian'>申请提现</el-button>

      </div>
    </el-dialog>
  </div>
</template>
<script>
  import md5 from 'md5'
  export default {
    data () {
      return {
        centerDialogVisible: false,
        bindCard: false,
        tixian: '',
        money: '',
        form: {
          amount: undefined,
          pass: undefined
        }
      }
    },
    created () {
    },
    computed: {
      myInfo () {
        return this.$store.state.myInfo
      }
    },
    methods: {
			request_tixian () {
        let params = {}
        Object.assign(params, this.form)
        params.pass = md5(params.pass)
				this.$api.saveCash(params).then(res => {
				  if (res.code === '000000') {
				    this.$message.success('提现申请成功，审核中...')
            this.centerDialogVisible = false
          }
        })
			},
			val_change () {
				console.log(this.tixian)
				var reg = /^[0-9]*$/
//				var arr = this.tixian.match(reg)
//				console.log(arr)
			}
    },
    watch: {
    	tixian (val, oldVal) {
//  		var reg = /[1-9]+/g
//  		var strNum = val.match(reg)
    	}
    }
  }
</script>
<style lang='less' scoped>
  .tixian-text {
    color: inherit;
  }

  .ti-content {
    width: 100%;
    height: 50px;
    font-size: 18px;
    text-align: center;
    line-height: 50px;
    span {
      display: inline-block;
    }
    .num {
      color: #09abe9;
      font-weight: bold;
    }
  }
  .ti-other {
    width: 100%;
    height: 50px;
    color: red;
    font-size: 16px;
    text-align: center;
    line-height: 50px;
  }
  .button {
    width: 100%;
    margin-top: 10px;
    text-align: center;

  }
</style>

